package com.online.controller;

        import com.online.dal.dao.ProductDAO;
        import com.online.dal.model.Product;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.RequestMapping;
        import org.springframework.web.bind.annotation.RequestMethod;
        import org.springframework.web.bind.annotation.RestController;
        import org.springframework.web.servlet.ModelAndView;

        import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController {

    @Autowired
    private ProductDAO productDAO;

    @RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView indexOfAll() throws Exception {
        ModelAndView mv = new ModelAndView("product");

        List<Product> productList = productDAO.queryByModel(new Product()) ;
        mv.addObject("productList", productList);
        return mv;
    }

}
